//
//  RecipInfoView.m
//  RentTable
//
//  Created by mac on 2024/11/30.
//

#import "RecipInfoView.h"

@interface RecipInfoView()

@property (nonatomic, strong) UILabel *nameLabel;


@property (nonatomic, strong) UILabel *phoneLabel;


@property (nonatomic, strong) UILabel *addressLabel;



@end

@implementation RecipInfoView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    self.backgroundColor = [UIColor whiteColor];
    
    self.nameLabel = [[UILabel alloc] init];
    self.nameLabel.text = @"收货人";
    self.nameLabel.textAlignment = NSTextAlignmentLeft;
    self.nameLabel.font = [UIFont pingFangSCRegularWithSize:13];
    self.nameLabel.textColor = myRGBHex(0x666666);
    [self addSubview:self.nameLabel];
    
    self.nameTextField = [[UITextField alloc] init];
    self.nameTextField.borderStyle = UITextBorderStyleNone;
    self.nameTextField.textAlignment = NSTextAlignmentRight;
    NSString *placeholderText = @"请输入姓名";
    NSDictionary *attributes = @{
        NSFontAttributeName: [UIFont pingFangSCMediumWithSize:13],
        NSForegroundColorAttributeName: myRGBHex(0xC7C7C7)
    };
    self.nameTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholderText attributes:attributes];
    
    [self addSubview:self.nameTextField];
    
    self.phoneLabel = [[UILabel alloc] init];
    self.phoneLabel.text = @"联系方式";
    self.phoneLabel.textAlignment = NSTextAlignmentLeft;
    self.phoneLabel.font = [UIFont pingFangSCRegularWithSize:13];
    self.phoneLabel.textColor = myRGBHex(0x666666);
    [self addSubview:self.phoneLabel];
    
    self.phoneTextField = [[UITextField alloc] init];
    self.phoneTextField.borderStyle = UITextBorderStyleNone;
    self.phoneTextField.textAlignment = NSTextAlignmentRight;
    NSString *phonePlaceholderText = @"请输入联系方式";
    NSDictionary *phoneattributes = @{
        NSFontAttributeName: [UIFont pingFangSCMediumWithSize:13],
        NSForegroundColorAttributeName: myRGBHex(0xC7C7C7)
    };
    self.phoneTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:phonePlaceholderText attributes:phoneattributes];
    [self addSubview:self.phoneTextField];
    self.addressLabel = [[UILabel alloc] init];
    self.addressLabel.text = @"收货地址";
    self.addressLabel.textAlignment = NSTextAlignmentLeft;
    self.addressLabel.font = [UIFont pingFangSCRegularWithSize:13];
    self.addressLabel.textColor = myRGBHex(0x666666);
    [self addSubview:self.addressLabel];
    
    self.addressTextField = [[UITextField alloc] init];
    self.addressTextField.borderStyle = UITextBorderStyleNone;
    self.addressTextField.textAlignment = NSTextAlignmentRight;
    NSString *addressPlaceholderText = @"请输入收货地址";
    NSDictionary *addressAttributes = @{
        NSFontAttributeName: [UIFont pingFangSCMediumWithSize:13],
        NSForegroundColorAttributeName: myRGBHex(0xC7C7C7)
    };
    self.addressTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:addressPlaceholderText attributes:addressAttributes];
    
    [self addSubview:self.addressTextField];
    
    [self setupLayout];
}

- (void)setupLayout {
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(14);
        make.top.equalTo(self).offset(12);
        make.height.mas_equalTo(17);
    }];
    
    [self.nameTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(-20);
        make.centerY.equalTo(self.nameLabel.mas_centerY);
        make.height.mas_equalTo(17);
    }];
    
    [self.phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(14);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(8);
        make.width.mas_equalTo(100);
    }];
    
    [self.phoneTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(-14);
        make.centerY.equalTo(self.phoneLabel.mas_centerY);
        make.right.equalTo(self).offset(-20);
    }];
    
    [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(14);
        make.top.equalTo(self.phoneLabel.mas_bottom).offset(8);
        make.width.mas_equalTo(100);
    }];
    
    [self.addressTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(-20);
        make.centerY.equalTo(self.addressLabel.mas_centerY);
    }];
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [self endEditing:YES];
}


@end
